/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "moto")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Moto.findAll", query = "SELECT m FROM Moto m"),
    @NamedQuery(name = "Moto.findByIdMoto", query = "SELECT m FROM Moto m WHERE m.idMoto = :idMoto"),
    @NamedQuery(name = "Moto.findByModeloMoto", query = "SELECT m FROM Moto m WHERE m.modeloMoto = :modeloMoto")})
public class Moto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Moto")
    private Integer idMoto;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "Modelo_Moto")
    private String modeloMoto;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idMoto")
    private Collection<MotoProd> motoProdCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idMoto")
    private Collection<ClieHasMoto> clieHasMotoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idMoto")
    private Collection<TipsOperacion> tipsOperacionCollection;
    @JoinColumn(name = "id_Ficha_Tecnina", referencedColumnName = "id_Ficha_Tecnina")
    @ManyToOne
    private FichaTecnica idFichaTecnina;
    @JoinColumn(name = "id_Marca", referencedColumnName = "id_Marca")
    @ManyToOne
    private Marcas idMarca;
    @JoinColumn(name = "id_Tipo_Moto", referencedColumnName = "id_Tipo_Moto")
    @ManyToOne(optional = false)
    private TipoMoto idTipoMoto;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idMoto")
    private Collection<ManualesMoto> manualesMotoCollection;

    public Moto() {
    }

    public Moto(Integer idMoto) {
        this.idMoto = idMoto;
    }

    public Moto(Integer idMoto, String modeloMoto) {
        this.idMoto = idMoto;
        this.modeloMoto = modeloMoto;
    }

    public Integer getIdMoto() {
        return idMoto;
    }

    public void setIdMoto(Integer idMoto) {
        this.idMoto = idMoto;
    }

    public String getModeloMoto() {
        return modeloMoto;
    }

    public void setModeloMoto(String modeloMoto) {
        this.modeloMoto = modeloMoto;
    }

    @XmlTransient
    public Collection<MotoProd> getMotoProdCollection() {
        return motoProdCollection;
    }

    public void setMotoProdCollection(Collection<MotoProd> motoProdCollection) {
        this.motoProdCollection = motoProdCollection;
    }

    @XmlTransient
    public Collection<ClieHasMoto> getClieHasMotoCollection() {
        return clieHasMotoCollection;
    }

    public void setClieHasMotoCollection(Collection<ClieHasMoto> clieHasMotoCollection) {
        this.clieHasMotoCollection = clieHasMotoCollection;
    }

    @XmlTransient
    public Collection<TipsOperacion> getTipsOperacionCollection() {
        return tipsOperacionCollection;
    }

    public void setTipsOperacionCollection(Collection<TipsOperacion> tipsOperacionCollection) {
        this.tipsOperacionCollection = tipsOperacionCollection;
    }

    public FichaTecnica getIdFichaTecnina() {
        return idFichaTecnina;
    }

    public void setIdFichaTecnina(FichaTecnica idFichaTecnina) {
        this.idFichaTecnina = idFichaTecnina;
    }

    public Marcas getIdMarca() {
        return idMarca;
    }

    public void setIdMarca(Marcas idMarca) {
        this.idMarca = idMarca;
    }

    public TipoMoto getIdTipoMoto() {
        return idTipoMoto;
    }

    public void setIdTipoMoto(TipoMoto idTipoMoto) {
        this.idTipoMoto = idTipoMoto;
    }

    @XmlTransient
    public Collection<ManualesMoto> getManualesMotoCollection() {
        return manualesMotoCollection;
    }

    public void setManualesMotoCollection(Collection<ManualesMoto> manualesMotoCollection) {
        this.manualesMotoCollection = manualesMotoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMoto != null ? idMoto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Moto)) {
            return false;
        }
        Moto other = (Moto) object;
        if ((this.idMoto == null && other.idMoto != null) || (this.idMoto != null && !this.idMoto.equals(other.idMoto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Moto[ idMoto=" + idMoto + " ]";
    }
    
}
